#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QEventLoop>
#include <QComboBox>

#include "ecat_manager/ecat_pdo_map.h"
#include "ecat_manager/ecat_slave_define.h"

#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    virtual void closeEvent(QCloseEvent *event) override;

private slots:
    void on_pb_sendcontrol_clicked();

    void on_cbx_servocnt_currentIndexChanged(int index);

    void on_spinBox_v_valueChanged(int arg1);

private:
    Ui::MainWindow *ui;
    QTimer* t1_; // communicate with servo
    QTimer* t2_; // refresh ui
    bool req_connect_{false};

private:
    status_word_t status_word[SERVO_NUM + 1] = {0};
    error_code_t error_code[SERVO_NUM + 1] = {0};
    position_actual_value_t act_pos[SERVO_NUM + 1] = {0};

};
#endif // MAINWINDOW_H
